import java.util.Scanner;

public class Game {
    Customer cs;
    Computer cp;
    int count =0;//对战次数
    Scanner sc =new Scanner(System.in);

    public void welcome(){
        System.out.println("******************");
        System.out.println("*********猜拳游戏开始********");
        System.out.println("******************");


    }
    public void menu() {
        int choice = 0;
        int chooes;
        int choose;
        do {
            System.out.println("出拳规则：1：石头；2：剪刀；3：布");
            if (cp.name == null) ;
            System.out.println("请选择对方的角色（1：佳；2：小佳；3：小佳佳）");
            choose = sc.nextInt();
            System.out.println("请输入你的姓名:");
            cs.name = sc.next();
            switch (choose) {
                case 1:
                    System.out.println(cs.name + "选择佳对战");
                    cp.name = "佳";
                    break;
                case 2:
                    System.out.println(cs.name + "选择小佳对战");
                    cp.name = "小佳";
                    break;
                case 3:
                    System.out.println(cs.name + "选择小佳佳对战");
                    cp.name = "小佳佳";
                    break;
                default:
                    System.out.println(cs.name + "你输错了，请重新选择人称");

            }


        } while (choose < 1 && choose > 3);

    }

    public  void  showResult() {
        switch (cs.caiquan) {
            case 1://你出石头
                switch (cp.caiquan) {
                    case 1:
                        System.out.println("牛：你和" + cp.name + "平局");
                        break;
                    case 2:
                        System.out.println("菜，你输了" + cp.name);
                        cp.score++;
                        break;
                    case 3:
                        System.out.println("牛装货：你赢了" + cp.name);
                        cs.score++;
                        break;
                }
                break;
            case 2://你出剪刀
                switch (cp.caiquan) {
                    case 2:
                        System.out.println("牛：你和" + cp.name + "平局");
                        break;
                    case 3:
                        System.out.println("菜，你输了" + cp.name);
                        cp.score++;
                        break;
                    case 1:
                        System.out.println("牛装货：你赢了" + cp.name);
                        cs.score++;
                        break;
                }
                break;
            case 3://你出布
                switch (cp.caiquan) {
                    case 1:
                        System.out.println("牛：你和" + cp.name + "平局");
                        break;
                    case 2:
                        System.out.println("菜，你输了" + cp.name);
                        cp.score++;
                        break;
                    case 3:
                        System.out.println("牛装货：你赢了" + cp.name);
                        cs.score++;
                        break;
                }
                break;


        }
        count++;//比赛次数＋1
    }
    public void report() {
        System.out.println(cs.name+"\tvs\t"+cp.score+"\t"+cs.name);
        System.out.println("对阵次数: "+count+";平局次数："+(count - cs.score-cp.score));
        System.out.println("姓名\t得分");
        System.out.println(cp.name+"\t"+cp.score);
        System.out.println(cs.name+"\t"+cs.score);
        if(cp.score>cs.score){
            System.out.println(cp.name+"以"+cp.score+"比"+cs.score+"取得最后的胜利！");
        } else if (cp.score<cs.score) {
            System.out.println(cs.name+"以"+cs.score+"比"+cp.score+"取得最后的胜利！");
        }else{
            System.out.println(cp.name+"以"+cp.score+"比"+cs.score+"战平对手喽！");

        }
    }
    public static void main(String[] args) {
        Game game = new Game();
        game.cs=new Customer();
        game.cp=new Computer();
        Scanner sc =new Scanner(System.in);
        do{
            game.welcome();
            game.menu();
            game.cs.showFirst();
            game.cp.showFirst();
            game.showResult();
            System.out.println("好宝宝，还要再玩一局吗？true/false");
        } while (sc.nextBoolean());
        game.report();
    }


}
